#ifndef ADDR_HPP
#define ADDR_HPP

#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>

#include <string.h>
#include <string>


class Addr
{
public:
Addr()
{
    memset(&_addr,0,sizeof _addr);
};

Addr(std::string IP,uint16_t PORT)
{
    memset(&_addr,0,sizeof _addr);
    _addr.sin_family = AF_INET;
    _addr.sin_addr.s_addr = inet_addr(IP.c_str());
    _addr.sin_port = htons(PORT);
    _len = sizeof _addr;
};

Addr(struct sockaddr_in addr):
_len(sizeof _addr)
{
    memset(&_addr,0,sizeof _addr);

    _addr.sin_family = AF_INET;
    _addr.sin_addr.s_addr = addr.sin_addr.s_addr;
    _addr.sin_port = addr.sin_port;
}

~Addr(){};

struct sockaddr_in* operator&()
{
    return &_addr;
}

socklen_t Len()
{
    return _len;
}
socklen_t* LenPtr()
{
    return &_len;
}
private:
struct sockaddr_in _addr; 
socklen_t _len;
};

#endif 

